package com.grj.park.boot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;


/**
 * @author: eren
 * @date: 2023-02-25 02:46
 * @description:
 */
@Configuration
public class SwaggerConfig {


    @Bean
    public Docket getDocket(Environment environment){

        Profiles profiles = Profiles.of("dev");
        boolean enable = environment.acceptsProfiles(profiles);

        return new Docket(DocumentationType.OAS_30)
                .enable(enable)
                .apiInfo(getApiInfo())
                .select()
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public ApiInfo getApiInfo(){

        return new ApiInfoBuilder()
                .title("用户管理-接口文档")
                .description("用户管理")
                .contact(new Contact("grj", "http://www.eren.fit","1450554809@qq.com"))
                .version("1.0")
                .build();
    }
}